package com.example.lwt.hellogit;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

import java.util.List;

public class MainActivity extends AppCompatActivity {

    BeearExpert mBeearExpert ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mBeearExpert = new BeearExpert();
        Button button = (Button) findViewById(R.id.test_click);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onClickFindBeer(view);
            }
        });

    }

    public void onClickFindBeer(View view) {
        TextView textView = (TextView) findViewById(R.id.brands);
        Spinner spinner = (Spinner) findViewById(R.id.spinner);

        List<String> brands = mBeearExpert.getBrands(spinner.getSelectedItem().toString());
        StringBuilder stringBuilder = new StringBuilder();
        for (String brand : brands) {
            stringBuilder.append(brand).append("\r\n");
        }

        textView.setText(stringBuilder);

    }

    public void goOtherAction(View view) {
        EditText message = (EditText) findViewById(R.id.message);
        String msg = message.getText().toString();

        Intent messageAc = new Intent(this, ReceiveMessageActivity.class);
        messageAc.putExtra("msg", msg);
        startActivity(messageAc);
//        Intent sendIntent = new Intent(Intent.ACTION_SEND);
//        sendIntent.setType("text/plain");
//        sendIntent.putExtra(Intent.EXTRA_TEXT, msg);
//        startActivity(Intent.createChooser(sendIntent, "TTTTITLE!!!!!!!!!!"));

    }
}
